/******************************************************************************
 * Copyright (C) 2023 ShenZhen Powerdata Information Technology Co.,Ltd All Rights
 * Reserved. 本软件为深圳博沃智慧科技有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、 复制、修改或发布本软件.
 *****************************************************************************/
package com.example.db.hangao;


import java.sql.*;

/**
 * @author Administrator
 * @Title: JdbcTest
 * @projectName 106-test-spring-boot
 * @description: TODO
 * @history 2023/11/14 20:19 新建
 * @since TODO 0.0.1
 */
public class JdbcTest {

    public static void main(String[] args) {
        Connection ct=null;
        PreparedStatement sm=null;
        ResultSet rs=null;
        try{
            //加载HighGo DB的驱动
            Class.forName("com.highgo.jdbc.Driver");
            ct= DriverManager.getConnection("jdbc:highgo://10.211.128.194:5866/bowo_db?serverTimezone=Asia/Shanghai","bowo", "Bwo@1234*");
            String sql="select * from jinan_yqyd.t_admin_rms_js where cjsj >= ?";


            sm=ct.prepareStatement(sql);

            sm.setTimestamp(1, new Timestamp(new java.sql.Date(System.currentTimeMillis()).getTime()));
//            sm.setObject(1, "2023-11-15 09:03:15.351+08");
            //执行查询语句
            System.out.println("sql====="+sql);
            rs=sm.executeQuery();
            //循环结果，并打印
            while(rs.next()){
                System.out.println("nmu===="+rs.getString(2)+"name===="+rs.getString(1));
            }
            //抛出异常
        }catch (Exception e){
            e.printStackTrace();
        }finally{
            //关闭数据库连接
            try {
                if(rs!=null){
                    rs.close();
                }
                if(sm!=null){
                    sm.close();
                }
                if(ct!=null){
                    ct.close();
                }
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }


    public static void testSql(String[] args) {
        Connection ct=null;
        PreparedStatement sm=null;
        ResultSet rs=null;
        try{
            //加载HighGo DB的驱动
            Class.forName("com.highgo.jdbc.Driver");
            ct= DriverManager.getConnection("jdbc:highgo://10.211.128.194:5866/bowo_db?serverTimezone=Asia/Shanghai","bowo", "Bwo@1234*");
            String sql="select * from jinan_yqyd.t_admin_rms_js where cjsj >= ?";
            sql="select * from jinan_yqyd.t_admin_rms_js where cjsj >= '2003-11-15 13:12:31.744'";


            sm=ct.prepareStatement(sql);

//            sm.setTimestamp(1, new Timestamp(new java.sql.Date(System.currentTimeMillis()).getTime()));
//            sm.setObject(1, "2023-11-15 09:03:15.351+08");
            //执行查询语句
            System.out.println("sql====="+sql);
            rs=sm.executeQuery();
            //循环结果，并打印
            while(rs.next()){
                System.out.println("nmu===="+rs.getString(2)+"name===="+rs.getString(1));
            }
            //抛出异常
        }catch (Exception e){
            e.printStackTrace();
        }finally{
            //关闭数据库连接
            try {
                if(rs!=null){
                    rs.close();
                }
                if(sm!=null){
                    sm.close();
                }
                if(ct!=null){
                    ct.close();
                }
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}
